package com.project.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.project.model.CityModel;
import com.project.service.CityService;

@Controller
@RequestMapping(value = "/city")
public class CityController {
	private static Logger logger = LoggerFactory.getLogger(CityController.class);
	
	@Autowired
	private CityService cityService;
	
	private final String moduleName = "";
	
	@RequestMapping(moduleName + "/listPinyin")
	public ModelAndView listPinyin(HttpServletRequest request) {
		ModelAndView mav = new ModelAndView();
		List<CityModel> citys = cityService.listCityModelOrderByPinyin();
		mav.addObject("list", citys);
		String letter_str = "A,B,C,D,E,F,G,H,J,K,L,M,N,O,P,Q,R,S,T,W,X,Y,Z";
		String[] letters = letter_str.split(",");
		mav.addObject("letters", letters);
		mav.setViewName("../city.jsp");
		return mav;
	}
}